package org.sunrise.game.game.message;

import org.sunrise.game.center.client.ReportClientMessageManager;
import org.sunrise.game.center.message.ReportMessage;
import org.sunrise.game.center.server.NodeManager;
import org.sunrise.game.common.log.LogCore;
import org.sunrise.game.common.message.MessageUtils;
import org.sunrise.game.game.server.GameManager;

/**
 * game 上报客户端 消息管理类
 * 收到master的消息后，进行处理
 */
public class GameReportMessageManager extends ReportClientMessageManager {
    public GameReportMessageManager(String nodeId) {
        super(nodeId);
    }

    @Override
    protected void pulseHandlerOne(Object data) {
        var message = MessageUtils.fromMessage((byte[]) data, ReportMessage.class);
        if (message.getType() == NodeManager.NODE_TYPE_EXTERNAL) {
            GameManager.getGameClient().connectExternal(message);
        }
//        LogCore.ReportClient.debug("recv msg, cur NodeId = { {} }, from NodeId = { {} }, messageId = { {} }, data = { {} }", getNodeId(), message.getNodeId(), message.getMessageId(), message);
    }
}
